<?php

namespace app\api\controller;

use app\common\controller\ApiBase;
use app\common\model\Area as AreaModel;

class Area extends ApiBase
{


    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];


    public function list()
    {
        $this->checkRequestParam(\app\common\validate\Area::class);
        $param = $this->request->param();
        $where = [];
        if ($this->request->has('pid')) {
            $where = ['pid' => $param['pid']];
        }

        $area = AreaModel::where($where)
            ->paginate($this->getPaginate());
        $data = $area->items();
        $count = $area->total();
        $this->success('成功', ['list' => $data, 'count' => $count]);
    }
}
